//
//  NSObject+UserTag.m
//  QTCategory
//
//  Created by 张俊博 on 2016/10/27.
//  Copyright © 2016年 CISDI. All rights reserved.
//

#import "NSObject+UserTag.h"
#import <objc/runtime.h>

static char const * const kUserTag    =   "kUserTag";

@implementation NSObject (UserTag)

- (void)setUserTag:(NSString *)userId
{
    objc_setAssociatedObject(self, kUserTag, userId, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (NSString *)userTag
{
    return objc_getAssociatedObject(self, kUserTag);
}

@end

@implementation NSArray (UserTag)

- (void)setUserTag:(NSString *)userId
{
    [super setUserTag:userId];
    for (id obj in self) {
        [obj setUserTag:userId];
    }
}


@end

@implementation NSDictionary (UserTag)

- (void)setUserTag:(NSString *)userId
{
    [super setUserTag:userId];
    for (id obj in self.allValues) {
        [obj setUserTag:userId];
    }
}

@end

